<script>
import { saveDynamicFormGroup } from '@/api/form'

export default {
  name: 'GroupConfig',
  props: {
    formId: null
  },
  data() {
    return {
      groupConfig: {
        name: '组名',
        key: '组编码'
      }
    }
  },
  methods: {
    onSubmit() {
      this.groupConfig.formId = this.formId
      saveDynamicFormGroup(this.groupConfig).then(() => {
        this.$message.success('保存成功')
        this.$emit('submit', this.groupConfig)
      })
    }
  }
}
</script>

<template>
  <el-form :model="groupConfig" size="small" label-width="80px" label-position="left">
    <el-form-item label="组名" prop="name">
      <el-input v-model="groupConfig.name" />
    </el-form-item>
    <el-form-item label="编码" prop="key">
      <el-input v-model="groupConfig.key" />
    </el-form-item>
    <el-form-item label="类型" prop="type">
      <el-select v-model="groupConfig.type" style="width: 100%">
        <el-option label="表单信息" value="form" />
        <el-option label="表单扩展" value="expansion" />
      </el-select>
    </el-form-item>
    <el-form-item prop="key">
      <el-button type="primary" @click="onSubmit">保存</el-button>
    </el-form-item>
  </el-form>
</template>

<style scoped lang="scss">

</style>
